package it.tcm.TeacherClassMate.persistent;

import java.sql.Connection;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

import org.apache.log4j.Logger;

public class DBConnection {
	
	private Logger logger = Logger.getLogger(this.getClass().getName());
	
	public Connection getDBConnection() {	
	  Connection  conn = null;
	  try {
		  Context ctx = new InitialContext();
		  DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/DStcm");   
		  conn = ds.getConnection();
		  conn.setAutoCommit(true);
	  } catch(Exception e) {
		 logger.error("Exception e "  + e);
	  }
	  return conn;
	}

}
